# !/usr/bin/env python3
# -*- encoding: utf-8 -*-

import asyncio
import sql
from model.user import User
from page import Page


@asyncio.coroutine
def test(loop):
    yield from sql.create_pool(
        user='root', password='root', db='blog', loop=loop)
    # user = User(
    #     name='Test1',
    #     email='test1@example.com',
    #     passwd='1234567890',
    #     image='about:blank')
    # yield from user.saveWithkey()
    # user = yield from User.findOne(8)
    # print(user)
    user = User()
    page = Page(curPage=1, pageSize=2)
    # count = yield from user.findCount()
    # print(count)
    page = yield from user.findPage(page)
    if page.curSize > 0:
        for item in page.resList:
            print(item)


loop = asyncio.get_event_loop()
loop.run_until_complete(test(loop))
